#include "exprunary.h"

ExprUnary::ExprUnary(Expr *unary,int fila,int col):Expr(fila,col)
{
    this->unary=unary;
}

void ExprUnary::setUnary(Expr *unary)
{
    this->unary=unary;
}

Expr *ExprUnary::getUnary()
{
    return this->unary;
}

void ExprUnary::setis(int tokentype)
{
    TokenType tt;
    is_ = tt.returntokenstring(tokentype);
}

string ExprUnary::is()
{
    return is_;
}

Tipo_ts *ExprUnary::validarSemantica(Tabla_Simbolos *tabla_de_tipo, Tabla_Simbolos *tabla_de_varaible)
{
    Tipo_ts *tts = this->getUnary()->validarSemantica(tabla_de_tipo,tabla_de_varaible);
    if(tts->is().compare("BOOLEANO")==0){
        return tts;
    }else{
        stringstream out;
        out<<"Se esperaba tipo Booleano// Fila:"<<this->getFila()<<endl;
        throw exception(out.str().c_str());
    }
}

Codigo_Lugar ExprUnary::generarCodigo(GenerarVariable* var,Tabla_Simbolos *tabla_de_tipo,Tabla_Simbolos *tabla_de_varaible)
{
    Codigo_Lugar unarystr = this->unary->generarCodigo(var,tabla_de_tipo,tabla_de_varaible);
    return unarystr;
}
